package com.javaspeak.designpatterns.go4.behavioural.command;

import java.util.Map;

/**
 * The RequestProcessor calls the execute(..) method of Command passing in the
 * request and response to it.
 * <p>
 * The Command to call the execute() method on is retrieved from the
 * RequestType stored in the request.
 *
 * @author John Dickerson
 */
public class RequestImpl implements Request {

    private Long requestId;
    private RequestType requestType;
    private Map<String,String> requestAttributes;


    /**
     * Constructor
     *
     * @param requestId The requestId provides a unique identify for the
     * request. The current implementation does not use it.
     *
     * @param requestType The RequestType holds the mapping to a Command.  The
     * RequestProcessor uses the RequestType from a Request to choose the
     * Command to call execute(..) on.
     *
     * @param requestAttributes Map of modified attributes.  The idea is
     * that the execute(..) method of Command will read the request
     * attributes; process them and then return them in a new map via the
     * callback method handleResponse(..) in the response argument of the
     * execute(..) method
     */
    public RequestImpl(
            Long requestId, RequestType requestType,
                Map<String,String> requestAttributes ){

        this.requestId = requestId;
        this.requestType = requestType;
        this.requestAttributes = requestAttributes;
    }


    @Override
    public Long getRequestId() {

        return requestId;
    }

    @Override
    public RequestType getRequestType() {

        return requestType;
    }

    @Override
    public Map<String, String> getRequestAttributes() {

        return requestAttributes;
    }
}
